package cn.dujc.superkid.adapter;


import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

import cn.dujc.superkid.R;
import cn.dujc.superkid.bean.ContactResult;
import cn.dujc.superkid.utils.ImageLoadHelper;


public class ContactUsAdpater extends RecyclerView.Adapter<ContactUsAdpater.ViewHolder> {
    private List<ContactResult.ContactEntity> list;
    public ContactUsAdpater(List<ContactResult.ContactEntity> list, Context context) {
        this.list = list;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_contactus, parent, false);
        return new ContactUsAdpater.ViewHolder(itemView);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.tv_name.setText(list.get(position).getName());
        ImageLoadHelper.loadImage(holder.iv_picurl,list.get(position).getPicurl());
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        private TextView tv_name;
        private ImageView iv_picurl;
        public ViewHolder(View itemView) {
            super(itemView);
            tv_name=itemView.findViewById(R.id.tv_name);
            iv_picurl=itemView.findViewById(R.id.iv_picurl);
        }
    }
}
